<?
/*************************************************
 * This file deals with the user download from 
 * the site and thus handles all playing around 
 * with the download stats!
 *************************************************/

require_once ("library/blocks/FileBlock.php");

function IncrementDownloads($file)
{
	$db = ConnectToDB();
	$num = $file['downloads']+1;
	$query = "UPDATE files SET downloads=".$num." WHERE id=".$file['id'];

	$result = mysql_query($query);
}

import_request_variables('gpc','i_');
session_start();

if (!isset($i_fileid) || !isset($_SESSION['s_loggedin']))
{
	echo 'If it were up to me, I\'d say your link\'s wrong.  Guess what...It <b>is</b> up to me! :P';
exit;
}

$f = GetFileDataById($i_fileid);
$file = $f[0];

IncrementDownloads($file);
?>

<html>
	<head>
	<? echo	'<meta http-equiv="refresh" content="1; url=notes/'.$file['file'].'">'; ?>
	<link rel="stylesheet" type="text/css" href="pack/styles/main.css">
	</head>
	<body>
		<div style="width:320px; background-color:#444444; color:#FFFFFF; padding:10px; margin:10px;">
			<? echo 'There goes your Saturday night! Enjoy!<br><br>If no download window has appeared yet, click <a class="file-link" href="notes/'.$file['file'].'">here.'; ?>
		</div>
	</body>
</html>
